<?php
	$id_list = uniqid();
?>
<div class="navi">
	<div class="left">
		<div class="btn-group">
			<?php 
				echo UI\Tag::btn('Add new', array(
					'href' => Uri::create('admin/preference/add')
				));			
				echo UI\Tag::btn('<span class="ico-equalizer"></span>', array (), true);
			?>
		</div>
	</div>
	<div class="right">
		<div id="<?php echo $id_list.'_title' ?>" class="page-title">Preferences Management</div>
		<div class="btn-actions" id="<?php echo $id_list.'_actions' ?>">
			<?php 
				echo UI\Tag::btn('<span class="ico-trashcan"></span>', array(
					'onclick' => 'App.doActionDelete(\''.Uri::create('admin/preference/delete').'\', \''.$id_list.'\')'
				));
			?>
		</div>
		<div class="btn-group">
			<?php echo UI\Admin\Tag::search_form(); ?>
		</div>
	</div>
</div>

<?php
	$table = UI\Admin\Table::forge($id_list);
	$table->add_header(Form::checkbox(array('class' => 'checkall', 'name' => '')));
	$table->add_header('Title');
	$table->add_header('Actions', array('width' => '8%'));	
	$table->add_page($zlist->pagination->render());
	
	foreach($zlist->posts as $preference)
	{
		$table->add_col(Form::checkbox(array('name' => 'ID[]', 'class' => 'check-item', 'value' => $preference->id)));
		$table->add_col(Html::anchor('admin/preference/edit/'.$preference->id, $preference->name));
		$table->add_col(
			Html::anchor('admin/preference/edit/'.$preference->id, 'Edit').
			' | '.
			'<a href="javascript:;" onclick="App.delete(\''.Uri::create('admin/preference/delete').'\', {id: '.$preference->id.'});">Del</a>'
		);
		$table->next();
	}
	
	echo $table->html();
?>